package com.xyb.controller;

import com.xyb.entity.FileId;
import com.xyb.service.FileService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("file")
public class FileController {
    @Resource
    private FileService fileService;

    /**
     * 单文件上传
     * @param file
     * @return
     */
    @PostMapping("file")
    public Long insertFile(MultipartFile file){
        return fileService.insertFile(file);
    }

    /**
     * 多文件上传
     * @param files
     * @return
     */
    @PostMapping("files")
    public FileId insertFiles(List<MultipartFile> files){
        return fileService.insertFiles(files);
    }
}
